package admin

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

// Response 统一响应结构
type Response struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

// ListResponse 列表响应结构
type ListResponse struct {
	List  interface{} `json:"list"`
	Total int64       `json:"total"`
}

// ResponseError 错误响应
func ResponseError(c *gin.Context, err error) {
	c.JSON(http.StatusOK, Response{
		Code:    500,
		Message: err.Error(),
		Data:    nil,
	})
}

// ResponseSuccess 成功响应
func ResponseSuccess(c *gin.Context, data interface{}) {
	c.JSON(http.StatusOK, Response{
		Code:    200,
		Message: "success",
		Data:    data,
	})
}

// ResponseList 列表响应
func ResponseList(c *gin.Context, list interface{}, total int64) {
	ResponseSuccess(c, ListResponse{
		List:  list,
		Total: total,
	})
}
